package com.jy.adscm.zltx.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.zltx.bean.JyDrawingUser;
import com.jy.adscm.zltx.mapper.mysql.JyDrawingUserMapper;
import com.jy.adscm.zltx.service.JyDrawingUserService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户与图纸关系 服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-07-02
 */
@Service
public class JyDrawingUserServiceImpl extends ServiceImpl<JyDrawingUserMapper, JyDrawingUser> implements JyDrawingUserService {

    @Override
    public boolean insertJyDrawingUser(List<JyDrawingUser> jyDrawingUsers) {
        //删除完之前全部的关系
        JyDrawingUser jyDrawingUser1 = jyDrawingUsers.get(0);
        Wrapper<JyDrawingUser> wrapper =new EntityWrapper<>();
        wrapper.eq("user_id",jyDrawingUser1.getUserId());
        List<JyDrawingUser> jyDrawingUsers1 = super.selectList(wrapper);
        for (JyDrawingUser jyDrawingUser : jyDrawingUsers1) {
            super.deleteById(jyDrawingUser.getId());
        }
        for (JyDrawingUser jyDrawingUser : jyDrawingUsers) {
            super.insert(jyDrawingUser);
        }
        return false;
    }
}
